import struct
from socketutils import recv_all
class NetMsg:
	def unpack(self,socket):
		bytes=socket.recv(4)
		t=struct.unpack("i",bytes)
		total=t[0]
		self.data=recv_all(socket,total)
		self.size=total
		return  4+total

	def pack(self,msg):
		i=len(msg)
		strSize=struct.pack('i',i)
		return strSize+msg
	pack=classmethod(pack)

		

